package com.yun.algorithmproblem.leetcode;

public class Leetcode1299 {

    public int[] replaceElements(int[] arr) {
        int n = arr.length;
        int maxValue=arr[n-1];
        arr[n-1]=-1;
        for (int i = n-2; i >=0 ; i--) {
            int temp=arr[i];
            arr[i]=maxValue;
            maxValue=Math.max(maxValue,temp);
        }
        return arr;
    }
}
